package com.supcalls;

import cn.hutool.core.io.FileUtil;
import java.io.File;
import java.nio.charset.Charset;
import java.nio.file.Path;
import java.nio.file.Paths;

public class FileUtilExample {
    public static void main(String[] args) {
        // 创建文件
        File file = FileUtil.touch("file.txt");
        System.out.println("文件已创建: " + file.getAbsolutePath());

        // 写入内容
        String contentToWrite = "Hello, Hutool!";
        FileUtil.writeString(contentToWrite, "file.txt", Charset.forName("UTF-8"));
        System.out.println("内容已写入: " + contentToWrite);

        // 读取文件内容
        String contentRead = FileUtil.readString("file.txt", Charset.forName("UTF-8"));
        System.out.println("读取的内容: " + contentRead);

        // 复制文件
        FileUtil.copy(Paths.get("file.txt"), Paths.get("copied_file.txt"));
        System.out.println("文件已复制到: copied_file.txt");

        // 删除文件
        //boolean deleted = FileUtil.del("file.txt");
        //System.out.println("文件删除成功: " + deleted);

        // 创建文件夹
        FileUtil.mkdir("folder");

    }
}

